package com.tebiecloud.base.server.service.impl;

import com.tebiecloud.base.client.model.IpLimitApi;
import com.tebiecloud.base.client.model.entity.GatewayIpLimit;
import com.tebiecloud.base.server.mapper.GatewayIpLimitApiMapper;
import com.tebiecloud.base.server.mapper.GatewayIpLimitMapper;
import com.tebiecloud.base.server.service.GatewayIpLimitService;
import com.tebiecloud.common.mybatis.base.service.impl.BaseServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 开放网关-IP访问控制-策略 服务实现类
 * @author tebie
 * @date 2019-08-01
 */
@Service
@Transactional(rollbackFor = Exception.class)
public class GatewayIpLimitServiceImpl extends BaseServiceImpl<GatewayIpLimitMapper, GatewayIpLimit> implements GatewayIpLimitService {

    @Autowired
    private GatewayIpLimitApiMapper gatewayIpLimitApiMapper;

    /**
     * 查询白名单
     * @return
     */
    @Override
    public List<IpLimitApi> getBlackList() {
        List<IpLimitApi> list = gatewayIpLimitApiMapper.selectIpLimitApi(0);
        return list;
    }

    /**
     * 查询黑名单
     * @return
     */
    @Override
    public List<IpLimitApi> getWhiteList() {
        List<IpLimitApi> list = gatewayIpLimitApiMapper.selectIpLimitApi(1);
        return list;
    }

}
